% ?- dupli([a,b,c],3,X).
% X=[a,a,a,b,b,b,c,c,c].

%dupli(+L1,+N,-L2).
dupli([],_,[]).
dupli(L1,N,L2):-
    dupli(L1,N,L2,[]).
    
dupli([],_,L2,L2):-!.
dupli([X|T],N,L2,Acc):-
    my_append(X,N,SubAcc,[]),
    append(Acc,SubAcc,Acc2),
    dupli(T,N,L2,Acc2).
    
my_append(_,0,L2,L2):-!.
my_append(X,N,L2,Acc):-
    append(Acc,[X],Acc1),
    N1 is N - 1,
    my_append(X,N1,L2,Acc1).
    